Repository navigation
databases: run permission init containers on the DB images - #506
Merged
Merged
Conversation
michaellzc
approved these changes
Nov 12, 2026
The correct-data-dir-permissions init containers on pgsql, codeintel-db and codeinsights-db used sourcegraph/alpine-3.14, a frozen 2023 build of an Alpine release that went end-of-life in May 2023. The init container only needs sh and chmod, which the database images already ship, so run it on the same image as the database container. Releases already pin those images, so the init container stays patched with them. The migrate-to-nonprivileged component copies the pgsql init container image into its chown init containers, so it now uses postgresql-16 too. Its busybox provides the same sh, stat and chown. Amp-Thread-ID: https://ampcode.com/threads/T-01a1c5fe-5015-76c2-bf19-d42868d2b979 Co-authored-by: Amp <amp@ampcode.com>
michaellzc
force-pushed
the
k/db-image-init-containers
branch
from
November 12, 2026 19:47
778448a to
c579543
Compare
michaellzc
enabled auto-merge (squash)
November 12, 2026 19:48
michaellzc
added a commit
to sourcegraph/deploy-sourcegraph-helm
that referenced
this pull request
Nov 13, 2026
A customer pointed out that the chart pulls `sourcegraph/alpine-3.14` for the `correct-data-dir-permissions` init containers on `pgsql`, `codeintel-db` and `codeinsights-db`. Alpine 3.14 went end-of-life in May 2023, and the image is worse than its name suggests: the monorepo pins its base to a November 2023 build and only re-tags it each release, so it still ships OpenSSL 1.1.1t, curl 8.4.0 and friends. The init container only runs `sh -c chmod`, which the database images already provide (busybox), so it now runs on the same image as the database container. The chart no longer references alpine at all, and there's nothing extra to pull or mirror. `alpine.image` is removed; `alpine.containerSecurityContext` and `alpine.resources` keep their names so existing overrides (e.g. the OpenShift example) still apply. Kustomize gets the same change in sourcegraph/deploy-sourcegraph-k8s#506. Once both land, sourcegraph/sourcegraph#18714 retires the `alpine-3.14` image. Manually tested on kind: deployed the three databases from `main`, wrote a row and loosened each data dir to 0777, then applied this branch. The init containers completed on the postgres images, the data dirs came back as 0700, and the data survived. A fresh install also came up cleanly. Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: Michael Lin <michael.lin@sourcegraph.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
correct-data-dir-permissionsinit containers onpgsql,codeintel-dbandcodeinsights-dbpullsourcegraph/alpine-3.14, which is a frozen November 2023 build of an Alpine release that went end-of-life in May 2023 (OpenSSL 1.1.1t, curl 8.4.0, ...), and customers' scanners rightly flag it. The init container only runssh -c chmod, which the database images already have via busybox, so it now uses the same pinned image as the database container. Themigrate-to-nonprivilegedcomponent copies the pgsql init container image into its chown init containers, so those now getpostgresql-16, whose busybox has the samesh,statandchown. Afterwards nothing in this repo references alpine.Sister change in Helm: sourcegraph/deploy-sourcegraph-helm#997. Docker Compose doesn't use the image. Once both land, sourcegraph/sourcegraph#18714 retires the
alpine-3.14image.Test plan: rendered every example overlay before and after; the only diff is the three init container images. With
migrate-to-nonprivilegedincluded, all its init containers resolve to the pinnedpostgresql-16. Ran the gitserver/searcher chown command from that component as root inpostgresql-16..buildkite/check-image-names.shpasses. The same init container change in Helm was exercised end to end on kind (upgrade from main with existing data, and fresh install).